#include "Settings.h"
#include "ValueHelpers.h"
namespace Cephei 
{ 
	namespace QL 
	{
		void Settings::EvaluationDate::set (DateTime datetime)
		{
			bool taken = false;
			bool% t = taken;
			try
			{
				_lock.Enter (t);
				QuantLib::Settings::instance().evaluationDate() = ValueHelper::Convert (datetime);
			}
			finally 
			{
				if (taken) _lock.Exit();
			}
		}
		DateTime Settings::EvaluationDate::get ()
		{
			bool taken = false;
			bool% t = taken;
			try
			{
				QuantLib::Date qd = QuantLib::Settings::instance().evaluationDate ();
				return ValueHelper::Convert (qd);
			}
			finally 
			{
				if (taken) _lock.Exit();
			}
		}
		void Settings::IncludeReferenceDateCashFlows::set (bool b)
		{
			bool taken = false;
			bool% t = taken;
			try
			{
				QuantLib::Settings::instance().includeReferenceDateCashFlows() = b;
			}
			finally 
			{
				if (taken) _lock.Exit();
			}
		}
		bool Settings::IncludeReferenceDateCashFlows::get ()
		{
			bool taken = false;
			bool% t = taken;
			try
			{
				bool b = QuantLib::Settings::instance().includeReferenceDateCashFlows ();
				return b;
			}
			finally 
			{
				if (taken) _lock.Exit();
			}
		}
		void Settings::IncludeTodaysCashFlows::set (bool b)
		{
			bool taken = false;
			bool% t = taken;
			try
			{
				QuantLib::Settings::instance().includeTodaysCashFlows() = b;
			}
			finally 
			{
				if (taken) _lock.Exit();
			}
		}
		bool Settings::IncludeTodaysCashFlows::get ()
		{
			bool taken = false;
			bool% t = taken;
			try
			{
				bool b = QuantLib::Settings::instance().includeTodaysCashFlows ();
				return b;
			}
			finally 
			{
				if (taken) _lock.Exit();
			}
		}
		void Settings::EnforcesTodaysHistoricFixings::set (bool b)
		{
			bool taken = false;
			bool% t = taken;
			try
			{
				QuantLib::Settings::instance().enforcesTodaysHistoricFixings() = b;
			}
			finally 
			{
				if (taken) _lock.Exit();
			}
		}
		bool Settings::EnforcesTodaysHistoricFixings::get ()
		{
			bool taken = false;
			bool% t = taken;
			try
			{
				bool b = QuantLib::Settings::instance().enforcesTodaysHistoricFixings ();
				return b;
			}
			finally 
			{
				if (taken) _lock.Exit();
			}
		}
		void Settings::ReferenceLocking::set (bool b)
		{	
			bool taken = false;
			bool% t = taken;
			try
			{
				_ReferenceLocking = b;
			}
			finally 
			{
				if (taken) _lock.Exit();
			}
		}
		bool Settings::ReferenceLocking::get ()
		{
			bool taken = false;
			bool% t = taken;
			try
			{
				return _ReferenceLocking;
			}
			finally 
			{
				if (taken) _lock.Exit();
			}
		}
	}
}